package UserFactory;

public class ProxyUser {
    private User realUser;

    public ProxyUser(User user) {
        this.realUser = user;
    }

    public void menu(){
        this.realUser.menu();
    }

    public void borrowBook(String bookName){
        System.out.println("检查用户权限");
        if(this.realUser instanceof NormalUser){
            ((NormalUser) this.realUser).borrowBook(bookName);
        }else{
            System.out.println("你没有权限！");
        }
    }

    public void addBook(String bookName){
        System.out.println("检查用户权限");
        if(this.realUser instanceof AdminUser){
            ((AdminUser) this.realUser).addBook(bookName);
        }else{
            System.out.println("你没有权限！");
        }
    }

}
